package com.kfm.base.collection;

public class OnlineUser {

    private static final OnlineUser INSTANCE = new OnlineUser();

    private int count;

    private OnlineUser(){}

    public static OnlineUser getInstance(){
        return INSTANCE;
    }

    public void addUser() {
        count++;
    }

    public int getCount() {
        return this.count;
    }
}

class Test {
    public static void main(String[] args) {
        login();
        login();

        OnlineUser onlineUser = OnlineUser.getInstance();
        System.out.println(onlineUser.getCount()); // 0
    }

    public static void login(){
        OnlineUser onlineUser = OnlineUser.getInstance();

        onlineUser.addUser();
    }
}
